package com.example.anew.journey.mynewjourney.firstchangelogic.firstChangeSearch;

import android.animation.ValueAnimator;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.anew.journey.mynewjourney.R;
import com.example.anew.journey.mynewjourney.firstchangelogic.firstChangeSearch.persenter.FirstChangeSearchPersenter;
import com.example.anew.journey.mynewjourney.firstchangelogic.firstChangeSearch.view.ISFirstChangeSearchView;
import com.umeng.analytics.MobclickAgent;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 杭州惟君医疗科技有限公司18
 * Created by 20433 on 2018/3/14
 */

public class FirstChangeSearchActivity extends AppCompatActivity implements ISFirstChangeSearchView {

    @Bind(R.id.activity_first_change_search_iv_search)
    ImageView activityFirstChangeSearchIvSearch;
    @Bind(R.id.activity_first_change_search_iv_delect)
    ImageView activityFirstChangeSearchIvDelect;
    @Bind(R.id.activity_first_change_search_et_search)
    EditText activityFirstChangeSearchEtSearch;
    @Bind(R.id.activity_first_change_search_rl_search)
    RelativeLayout activityFirstChangeSearchRlSearch;
    @Bind(R.id.activity_first_change_search_tv_cancel)
    TextView activityFirstChangeSearchTvCancel;
    @Bind(R.id.activity_search_toolbar)
    Toolbar activitySearchToolbar;
    @Bind(R.id.activity_first_change_search_recyclerview_hot_search)
    RecyclerView activityFirstChangeSearchRecyclerviewHotSearch;
    @Bind(R.id.activity_first_change_search_recyclerview_search_history)
    RecyclerView activityFirstChangeSearchRecyclerviewSearchHistory;
    @Bind(R.id.activity_first_change_search_tv_clear_record)
    TextView activityFirstChangeSearchTvClearRecord;
    @Bind(R.id.activity_first_change_search_progressBar)
    ProgressBar activityFirstChangeSearchProgressBar;
    private int i = 0;


    private FirstChangeSearchPersenter mFirstChangeSearchPersenter = new FirstChangeSearchPersenter(this);
    private ValueAnimator animator;
    private ValueAnimator animator1;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_first_change_search);
        ButterKnife.bind(this);
        initDate();
    }

    // 初始化数据
    private void initDate() {
        mFirstChangeSearchPersenter.initRecyclerviewHotSearch(activityFirstChangeSearchRecyclerviewHotSearch);
        mFirstChangeSearchPersenter.initRecyclerviewSearchHistory(activityFirstChangeSearchRecyclerviewSearchHistory);
    }

    @OnClick({R.id.activity_first_change_search_iv_delect, R.id.activity_first_change_search_tv_cancel, R.id.activity_first_change_search_tv_clear_record})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.activity_first_change_search_iv_delect:
                mFirstChangeSearchPersenter.onClickDelect();
                break;
            case R.id.activity_first_change_search_tv_cancel:
                mFirstChangeSearchPersenter.onClickcancel();
                break;
            case R.id.activity_first_change_search_tv_clear_record:
                mFirstChangeSearchPersenter.onClickClearRecord();
                break;
        }
    }
    // TODO 获取焦点
    @Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);

    }
    // TODO 失去焦点  可以进行一些轻量级的存储数据和去初始化工作
    @Override
    protected void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);

    }
    // 显示提示Toast信息
    @Override
    public void showToastInformation(String str) {
        Toast.makeText(FirstChangeSearchActivity.this, str, Toast.LENGTH_SHORT).show();
    }

    // 获取输入的信息
    @Override
    public String getInputInformation() {
        return activityFirstChangeSearchEtSearch.getText().toString().trim();
    }

    // 设置输入的信息
    @Override
    public void setInputInformation(String str) {
        activityFirstChangeSearchEtSearch.setText(str);
    }

    //页面跳转
    @Override
    public void toOtherActivity() {

    }

    //取消
    @Override
    public void cancel() {
        finish();
    }

    // 显示进度
    @Override
    public void displayProgress() {
        activityFirstChangeSearchProgressBar.setVisibility(View.VISIBLE);
        mFirstChangeSearchPersenter.progressBarAnimation(activityFirstChangeSearchProgressBar);
    }
    // 隐藏进度
    @Override
    public void hiddenProgress() {
        activityFirstChangeSearchProgressBar.setVisibility(View.GONE);
    }


}
